import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class JedisClusteTest {
    public static void main(String[] args){

        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();

        Set<HostAndPort> ports = new HashSet<>();
        ports.add(new HostAndPort("192.168.44.129",7001));
        ports.add(new HostAndPort("192.168.44.129",7002));
        ports.add(new HostAndPort("192.168.44.129",7003));
        ports.add(new HostAndPort("192.168.44.129",7004));
        ports.add(new HostAndPort("192.168.44.129",7005));
        ports.add(new HostAndPort("192.168.44.129",7006));
        ports.add(new HostAndPort("192.168.44.129",7007));
        ports.add(new HostAndPort("192.168.44.129",7008));

        JedisCluster cluster = new JedisCluster(ports,3000,jedisPoolConfig);
        Map<String, JedisPool> mapCluster = cluster.getClusterNodes();
        cluster.set("city1","深圳");
        String msg = cluster.get("city1");
        System.out.println("jedis cluter获取到的值为:"+msg);
    }
}
